<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <script>

        //1.创建核心对象
        var xhttp;
        if(window.XMLHttpRequest){
            xhttp = new XMLHttpRequest();
        }else {
            xhttp = new ActiveXObject("Microsoft.XMLHTTP")
        }


        //2.发送请求,因为是两个独立的Html和Servlet，因此需要全路径
        xhttp.open("GET", "http://localhost/ajaxServlet");
        xhttp.send();



        //3.响应数据
        xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                    //弹框
                    alert(this.responseText)

            }
        };


    </script>

</body>
</html>